﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Caifu.Spiders
{
	class DateUtil
	{
		/// <summary>
		/// 当前时间是否是采集时间
		/// </summary>
		/// <param name="date">输出：所采集净值的日期</param>
		/// <returns></returns>
		public static bool NowIsSpiderTime(out DateTime date)
		{
			var hour = DateTime.Now.Hour;

			if (hour > 9 && hour < 18)
			{// 该时间段内不进行采集
				date = DateTime.MinValue;
				return false;
			}

			if (hour >= 0 && hour <= 9)
			{// 在0-9点之间，采集前一天的净值 
				date = DateTime.Today.AddDays(-1);
			}
			else
			{
				date = DateTime.Today;
			}

			return true;
		}

		public static bool NowIsCheckTime(out DateTime date)
		{
			var hour = DateTime.Now.Hour;

			if (hour > 9 && hour < 18)
			{// 该时间段内不进行核对
				date = DateTime.MinValue;
				return false;
			}

			if (hour >= 0 && hour <= 9)
			{// 在0-9点之间，核对前一天的净值 
				date = DateTime.Today.AddDays(-1);
			}
			else
			{
				date = DateTime.Today;
			}

			return true;
		}
	}
}
